<?php
/**
 * Created by PhpStorm.
 * User: 12133
 * Date: 2025/6/20
 * Time: 14:52
 */

namespace app\model;


class Nav extends Base
{
    protected $append = [
        'images_id',
        'web_type_text',
        'isshow_text'
    ];

    public function getSonCountAttr($value,$data){
        return $this->where('pid',$data['id'])->count();
    }

    public function getIsshowTextAttr($value,$data){
        if ($data['isshow'] == 1)
            return '显示';
        else
            return '不现实';
    }

    public function getWebTypeTextAttr($value,$data){
        if ($data['web_type'] == 1)
            return '详情页面';
        else
            return '列表页面';
    }

    public function content(){
        return $this->hasOne(InfoContent::class,'id','content_id');
    }

    public function son(){
        return $this->hasMany(Nav::class,'pid','id');
    }
}